package com.by.sql;

/**
 * @version 1.0
 * @Author 彭彦彬
 * @Date 2025/4/9 11:01
 * @注释
 */
import java.util.ArrayList;
import java.util.List;

public class QueryWrapper<T> {
    private final StringBuilder sql = new StringBuilder();
    private final List<Object> params = new ArrayList<>();

    public QueryWrapper<T> eq(String column, Object value) {
        appendCondition(column + " = ?", value);
        return this;
    }

    public QueryWrapper<T> like(String column, String value) {
        appendCondition(column + " LIKE ?", "%" + value + "%");
        return this;
    }

    private void appendCondition(String condition, Object param) {
        if (sql.length() > 0) sql.append(" AND ");
        sql.append(condition);
        params.add(param);
    }

    public String getSql() {
        return sql.toString();
    }

    public List<Object> getParams() {
        return params;
    }
}
